import React from 'react';
import { getCompanyTree } from '@/services/components/userform';
import { TreeSelectForm } from '@/components/UserForm';

export default React.forwardRef(({ companyId, ...rest }, ref) => (
    <TreeSelectForm
        params={{ companyId }}
        requireParam={['companyId ']}
        getData={params =>
            getCompanyTree(params).then(res => {
                if (res && res.code === 10000 && res.data) {
                    return res.data || [];
                }
                return [];
            })
        }
        fieldsName={{
            value: 'id',
            title: 'companyName'
        }}
        Props={{
            placeholder: '请选择所属公司',
            style: { minWidth: 200 },
            showArrow: true
        }}
        ref={ref}
        {...rest}
    />
));
